﻿var xmlPath = ""; //XML文件地址，作为参数传递
var xmlDoc = null; //XML文档内容
/*
*   加载XML文档
*   @param  filePath 文件相对路径
*/
function XMLLoad(filePath) {
    try {
        if (window.ActiveXObject) {
            xmlDoc = new ActiveXObject('Msxml2.DOMDocument.3.0');
            xmlDoc.async = false;
            xmlDoc.load(filePath);
        }
        else if (document.implementation && document.implementation.createDocument) {
            xmlDoc = document.implementation.createDocument('', '', null);
            xmlDoc.load(filePath);
        }
        else {
            xmlDoc = null;
        }
    }
    catch (e) {
        xmlDoc = null;
    }
    return xmlDoc;
}
/** 
* 解析XML文件函数 
* @param name 属性名称 格式如:user.name 
*/
function getXMLProperty(name) {
    var keys = name.split('.');
    var node = xmlDoc.documentElement;
    for (var i = 0; i < keys.length; i++) {
        var childs = node.childNodes;
        var key = keys[i];
        for (var k = 0; k < childs.length; k++) {
            var child = childs[k];
            if (child.nodeName == key) {
                if (child.childNodes.length == 1) {
                    return child.text;
                } else {
                    node = child;
                    break;
                }
            }
        }
    }
    return "";
}



///*
//*   设置时间
//*/
//function setTime() {
////    if (xmlDoc == null) { XMLLoad('../timeconfig.xml'); }
////    var t = parseInt(getXMLProperty('timeoperation.time[@value="DXT"]'));
//    var obj = document.getElementById('EndDate');
//    //    obj.value = $dp.cal.getP('y') + '/' + $dp.cal.getP('M') + '/' + $dp.cal.getP('d') + ' ' + (parseInt($dp.cal.getP('H')) + t) + ':' + $dp.cal.getP('m') + ':' + $dp.cal.getP('s');
////    obj.value = WdatePicker({ dateFmt: '#F{$dp.$D(\'StartDate\',{h:-2});}' }).value;
////    obj.disabled = true;
//}






//设置一个元素在页面居中，元素的position应为absolute
function setElementInPageCenter(obj) {
    obj.style.left = document.body.clientWidth / 2 - obj.clientWidth / 2;
    obj.style.top = document.body.clientHeight / 2 - obj.clientWidth / 2;
}
//检验值
function checkValue() {
    if ((equipname.lastSuccessValue == null || equipname.lastSuccessValue == '') && (indicators.lastSuccessText == '-----全部----')) {
        alert('请选择统计指标!');
        return false;
    }
    return true;
}